"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/request.js"),
  t = {
    __name: "partner-details",
    setup(t) {
      const u = e.ref(!1),
        n = e.ref([{
          name: "男",
          value: 1
        }, {
          name: "女",
          value: 0
        }]),
        l = e.ref(0);
      const i = e.reactive({
          contact: "",
          gender: 1,
          message: ""
        }),
        v = e.ref(""),
        r = e.ref(!1),
        o = e.ref(!1),
        s = e.ref(!0),
        c = e.ref({}),
        m = e.reactive({
          quantity: 0,
          male: 0,
          female: 0
        });
      async function d() {
        const e = await a.requestApi("/signup_query", {
            id: v.value
          }),
          t = await a.requestApi("/companion_details", {
            id: v.value
          });
        "001" == e.data ? (r.value = !1, o.value = !0, s.value = !1) : "002" == e.data ? (r.value = !0, o.value = !1, s.value = !1) : (r.value = !1, o.value = !1, s.value = !0), c.value = t.data[0], m.quantity = t.data[0].signups.length, t.data[0].signups.forEach((e => {
          0 === e.gender ? m.female++ : m.male++
        }))
      }
      async function g() {
        e.wx$1.showLoading({
          title: "提交中",
          mask: !0
        }), await a.requestApi("/sign_up_partner", {
          signup_id: v.value,
          contact_inform: i.contact,
          gender: i.gender,
          introduce: i.message
        }, "POST"), await d(), u.value = !1
      }

      function f() {
        e.wx$1.navigateTo({
          url: "/pages/companion/managing-member?_id=" + v.value
        })
      }
      return e.onLoad((async e => {
        const a = e._id;
        v.value = a, await d()
      })), (a, t) => e.e({
        a: e.f(c.value.image, ((e, a, t) => ({
          a: e,
          b: a
        }))),
        b: e.f(c.value.author_data, ((a, t, u) => e.e({
          a: a.avatarUrl,
          b: e.t(a.nickname)
        }, (r.value, {}), o.value ? {
          c: e.o(f, t)
        } : {}, {
          d: t
        }))),
        c: e.t(c.value.timestamp),
        d: r.value,
        e: o.value,
        f: e.t(c.value.description),
        g: e.t(c.value.companion_time),
        h: e.t(c.value.city),
        i: e.t(c.value.full_address),
        j: e.t(c.value.number_of_people),
        k: m.quantity > 0
      }, m.quantity > 0 ? {
        l: e.t(m.quantity),
        m: e.t(m.male),
        n: e.t(m.female),
        o: e.f(c.value.signups, ((a, t, u) => ({
          a: a.avatarUrl,
          b: e.t(a.nickname),
          c: t
        })))
      } : {}, {
        p: s.value
      }, s.value ? {
        q: e.o((e => u.value = !0))
      } : {}, {
        r: i.contact,
        s: e.o((e => i.contact = e.detail.value)),
        t: e.f(n.value, ((a, t, u) => ({
          a: e.t(a.name),
          b: t,
          c: e.n(t == l.value ? "gengderStyle" : ""),
          d: e.o((e => function (e, a) {
            l.value = e, i.gender = a
          }(t, a.value)), t)
        }))),
        v: i.message,
        w: e.o((e => i.message = e.detail.value)),
        x: e.o(g),
        y: e.o((e => u.value = !0)),
        z: u.value,
        A: e.o((e => u.value = !1))
      })
    }
  };
wx.createPage(t);